use axum::{Extension, Json};
use crate::core::engine::{Task, OpsPanelCore};
use serde_json::Value;
use anyhow::Result;
use http::StatusCode;

pub async fn execute_batch_handler(
    Extension(core): Extension<OpsPanelCore>,
    Json(tasks): Json<Vec<Task>>,
) -> Result<Json<Vec<Result<Value>>>, StatusCode> {
    if tasks.len() > 100 {
        return Err(StatusCode::BAD_REQUEST);
    }
    
    let results = core.execute_batch(tasks).await;
    Ok(Json(results))
}